package joctavetests.toolbox.joctave.matrix;

import joctave.core.interpreter.Interpreter;
import joctave.tools.junit.framework.*;

public class testAny extends TestCase {
	protected Interpreter ml;
	
    public testAny(String name) {
		super(name);
	}
	public static void main (String[] args) {
		joctave.tools.junit.textui.TestRunner.run (suite());
	}
	protected void setUp() {
		ml = new Interpreter(true);
	}
    protected void tearDown() {
        ml = null;
    }

	public static Test suite() {
		return new TestSuite(testAny.class);
	}

    /****** any() **********************************************************/
	public void testAny01() {
        ml.executeExpression("a=any(1.123);");
		assertTrue(1.0 == ml.getScalarValueRe("a"));
	}
    public void testAny02() {
        ml.executeExpression("b=any(0.0)");
		assertTrue(false == ml.getScalarValueBoolean("b"));
	}
    public void testAny03() {
        double[][] a = {{0.0, 0.0, 0.0},{0.0, 5.0, 0.0},{0.0, 0.0, 1.0}};
        double[][] b = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}};
        ml.setArray("a", a, b);
        ml.executeExpression("z = any(a)");
		assertTrue(1.0 == ml.getScalarValueRe("z"));
	}
    public void testAny04() {
        double[][] a = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}};
        ml.setArray("e", a, a);
        ml.executeExpression("z = any(e)");
		assertTrue(false == ml.getScalarValueBoolean("z"));
	}
 
}
